package com.feiyu.sys.jwt

/**
 * Created by zdy on 2017/12/1.
 */
enum TokenState {
    /**
     * 过期
     */
    EXPIRED("EXPIRED"),
    /**
     * 无效(token不合法)
     */
    INVALID("INVALID"),
    /**
     * 有效的
     */
    VALID("VALID")

    String  state

    TokenState(String state) {
        this.state = state
    }

    /**
     * 根据状态字符串获取token状态枚举对象
     * @param tokenState
     * @return
     */
    static TokenState getTokenState(String tokenState){
        TokenState[] states = TokenState.values()
        TokenState ts = null

        states.each {
            state ->
                if(state.toString().equals(tokenState)){
                    ts = state
                }

        }
        return ts
    }

    @Override
    String toString(){
        return this.state
    }


}